package com.ruicar.afs.cloud.afscase.autoaudit.service.impl;

import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruicar.afs.cloud.afscase.autoaudit.service.IRuleAtomDataService;
import com.ruicar.afs.cloud.afscase.channel.entity.ChannelAffiliatedUnits;
import com.ruicar.afs.cloud.afscase.channel.entity.ChannelBaseInfo;
import com.ruicar.afs.cloud.afscase.channel.entity.ChannelReceivablesAccount;
import com.ruicar.afs.cloud.afscase.channel.entity.ChannelRiskInfo;
import com.ruicar.afs.cloud.afscase.channel.service.*;
import com.ruicar.afs.cloud.afscase.infomanagement.entity.*;
import com.ruicar.afs.cloud.afscase.infomanagement.service.*;
import com.ruicar.afs.cloud.afscase.loanapprove.entity.CarInsuranceInfo;
import com.ruicar.afs.cloud.afscase.loanapprove.entity.CarInvoiceInfo;
import com.ruicar.afs.cloud.afscase.loanapprove.entity.LoanBankCardInfo;
import com.ruicar.afs.cloud.afscase.loanapprove.service.CarInsuranceInfoService;
import com.ruicar.afs.cloud.afscase.loanapprove.service.CarInvoiceInfoService;
import com.ruicar.afs.cloud.afscase.loanapprove.service.LoanBankCardInfoService;
import com.ruicar.afs.cloud.bizcommon.business.entity.FinCostDetails;
import com.ruicar.afs.cloud.bizcommon.business.entity.FinFinancingItems;
import com.ruicar.afs.cloud.bizcommon.business.service.ApplyFinancingItemsService;
import com.ruicar.afs.cloud.common.core.enums.AfsEnumUtil;
import com.ruicar.afs.cloud.common.modules.afscorebusiness.enums.*;
import cn.hutool.core.date.DateUtil;
import com.ruicar.afs.cloud.image.entity.ComAttachmentFile;
import com.ruicar.afs.cloud.image.enums.AttachmentUniqueCodeEnum;
import com.ruicar.afs.cloud.image.service.ComAttaManageService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Description:
 * @Author: fangchenliang
 * @Date: 2020/8/8 10:31
 */
@Service
@AllArgsConstructor
@Slf4j
public class RuleAtomDataService implements IRuleAtomDataService {

    private CaseBaseInfoService caseBaseInfoService;

    private CaseCarInfoService caseCarInfoService;

    private CaseCostInfoService caseCostInfoService;

    private ChannelRiskInfoService channelRiskInfoService;

    private ChannelAffiliatedUnitsService channelAffiliatedUnitsService;

    private CaseChannelInfoService caseChannelInfoService;

    private CaseCarStyleDetailService carStyleDetailInfoService;

    private ChannelBaseInfoService channelBaseInfoService;

    private CaseContractInfoService caseContractInfoService;

    private CarInsuranceInfoService carInsuranceInfoService;

    private LoanBankCardInfoService loanBankCardInfoService;

    private CarInvoiceInfoService carInvoiceInfoService;

    private CaseCustInfoService caseCustInfoService;

    private ComAttaManageService comAttaManageService;

    private final ChannelAccountInfoService accountInfoService;

    private final CaseCustIndividualService caseCustIndividualService;

    private final ApplyFinancingItemsService applyFinancingItemsService;

    public JSONObject getCommonAtomRunParams(String applyNo){
        JSONObject runParams = new JSONObject();
        CaseBaseInfo caseBaseInfo = caseBaseInfoService.getOne(Wrappers.<CaseBaseInfo>query().lambda()
                .eq(CaseBaseInfo::getApplyNo, applyNo));
        log.info("------------------公共原子规则组装 Start --------------------");
        if (ObjectUtils.isNotEmpty(caseBaseInfo)) {
            /**业务类型*/
            runParams.put("businessType", caseBaseInfo.getBusinessType());

            /**车辆类型*/
            runParams.put("carType", caseBaseInfo.getCarType());

            /**车辆属性*/
            runParams.put("carNature", caseBaseInfo.getCarNature());

            /**运营方式*/
            runParams.put("operateWay", caseBaseInfo.getOperateWay());

            /**挂靠方式*/
            runParams.put("affiliatedWay", caseBaseInfo.getAffiliatedWay());

            /**金融产品*/
            runParams.put("productId", Convert.toStr(caseBaseInfo.getProductId(), ""));

            /**购车目的*/
            runParams.put("carPurpose",Convert.toStr(caseBaseInfo.getCarPurpose(), ""));

            /**累加贷额*/
            runParams.put("loanAmountAddUp",caseBaseInfo.getTotalLoanAmt());
        }
        /**---------------------------------     车辆信息     ----------------------------------**/
        CaseCarInfo caseCarInfo = caseCarInfoService.getOne(Wrappers.<CaseCarInfo>query().lambda()
                .eq(CaseCarInfo::getApplyNo, applyNo));
        if (ObjectUtils.isNotEmpty(caseCarInfo)) {
            /**车辆级别*/
            runParams.put("carBodyClass", caseCarInfo.getCarBodyClass());
            /**车辆品牌*/
            runParams.put("brandName", caseCarInfo.getBrandName());
            /**车型*/
            runParams.put("modelCode", caseCarInfo.getModelCode());
            /**购车地省份*/
            runParams.put("purchaseProvince",caseCarInfo.getPurchaseProvince());
            /**购车地城市*/
            runParams.put("purchaseCity",caseCarInfo.getPurchaseCity());
            /**上牌省份*/
            runParams.put("licenseProvince",caseCarInfo.getLicenseProvince());
            /**上牌城市*/
            runParams.put("licenseCity",caseCarInfo.getLicenseCity());

            if(!org.springframework.util.ObjectUtils.isEmpty(caseCarInfo)){
                if(caseBaseInfo.getAffiliatedWay().equals(AffiliatedWayEnum.PERSONAL_AFFILIATED.getCode())){
                    /**挂靠单位*/
                    runParams.put("affiliatedName",caseCarInfo.getIndBusinessName());
                }
                if(caseBaseInfo.getAffiliatedWay().equals(AffiliatedWayEnum.COMPANY_AFFILIATED.getCode())
                        ||caseBaseInfo.getAffiliatedWay().equals(AffiliatedWayEnum.NETWORK_CAR_AFFILIATED.getCode())){
                    ChannelAffiliatedUnits channelAffiliatedUnits = channelAffiliatedUnitsService
                            .getOne(Wrappers.<ChannelAffiliatedUnits>lambdaQuery().eq(ChannelAffiliatedUnits::getId, Long.valueOf(caseCarInfo.getAffCompanyId())));
                    if (null != channelAffiliatedUnits) {
                        runParams.put("affiliatedName",channelAffiliatedUnits.getAffiliatedName());
                    }else {
                        runParams.put("affiliatedName","");
                    }
                }
                if(caseBaseInfo.getAffiliatedWay().equals(AffiliatedWayEnum.NO.getCode())){
                    runParams.put("affiliatedName","");
                }
            }
        }

        /**---------------------------------     车辆详情     ----------------------------------**/
        List<CaseCarStyleDetail> cartyleDetailInfo = carStyleDetailInfoService.list(Wrappers.<CaseCarStyleDetail>query().lambda()
                .eq(CaseCarStyleDetail::getCarId, caseCarInfo.getId()));

        if (CollectionUtils.isNotEmpty(cartyleDetailInfo)) {
            /**是否新能源*/
            runParams.put("isGreen", cartyleDetailInfo.get(0).getIsGreen());

            /** 资产主类*/
            runParams.put("assetsClass", cartyleDetailInfo.get(0).getCarType());

            /** 资产子类*/
            runParams.put("carTypeDetail", cartyleDetailInfo.get(0).getCarTypeDetail());
        }

        /**贷款总额=附加贷贷款金额+车辆贷款金额*/
        BigDecimal loanAmount = BigDecimal.ZERO;
        /**附加贷贷款金额*/
        BigDecimal appendLoanAmount=BigDecimal.ZERO;
        /**车辆贷款金额*/
        BigDecimal carLoanAmount = BigDecimal.ZERO;

        /**贴息金额(合计)=车辆贴息金额+附加贷贷款金额*/
        BigDecimal tailPayAmt = BigDecimal.ZERO;
        /**车辆贴息金额*/
        BigDecimal carDiscountAmount=BigDecimal.ZERO;
        /**附加贷贴息金额*/
        BigDecimal appendDiscountAmount=BigDecimal.ZERO;

        /**尾款金额(合计)=车辆尾款金额+附加贷尾款金额*/
        BigDecimal subsidyTotalAmt = BigDecimal.ZERO;
        /**附加贷尾款金额*/
        BigDecimal appendFinalPayment=BigDecimal.ZERO;
        /**车辆尾款金额*/
        BigDecimal carFinalPayment=BigDecimal.ZERO;

        /**车辆贷款详情*/
        FinCostDetails carAmtCostInfoCar = caseCostInfoService.getOne(Wrappers.<FinCostDetails>query().lambda()
                .eq(FinCostDetails::getApplyNo, applyNo)
                .eq(FinCostDetails::getCostType, CostTypeEnum.CARAMT.getCode())
        );
        if (ObjectUtils.isNotEmpty(carAmtCostInfoCar)) {
            /**首付比例*/
            runParams.put("downPayScale", carAmtCostInfoCar.getDownPayScale().divide(new BigDecimal(100),2,BigDecimal.ROUND_HALF_UP));
            /**还款方式*/
            runParams.put("repayMode", carAmtCostInfoCar.getAlgorithmType());
            /**贷款期限*/
            runParams.put("loanTerm",carAmtCostInfoCar.getLoanTerm());

            carLoanAmount=carLoanAmount.add(Convert.toBigDecimal(carAmtCostInfoCar.getLoanAmt(), BigDecimal.ZERO));
            runParams.put("carLoanAmount",carLoanAmount);

            carDiscountAmount=carDiscountAmount.add(Convert.toBigDecimal(carAmtCostInfoCar.getDiscountAmt(), BigDecimal.ZERO));
            runParams.put("carDiscountAmount",carDiscountAmount);

            carFinalPayment=carFinalPayment.add(Convert.toBigDecimal(carAmtCostInfoCar.getTailPayAmt(), BigDecimal.ZERO));
            runParams.put("carFinalPayment",carFinalPayment);
        }

        /**  车款融资信息附件贷 **/
        FinCostDetails carAmtCostInfoAdd = caseCostInfoService.getOne(Wrappers.<FinCostDetails>query().lambda()
                .eq(FinCostDetails::getApplyNo, applyNo)
                .eq(FinCostDetails::getCostType, CostTypeEnum.AFFIXAMT.getCode())
        );
        appendLoanAmount=appendLoanAmount.add(Convert.toBigDecimal(carAmtCostInfoCar.getAddAmt(), BigDecimal.ZERO));
        if (ObjectUtils.isNotEmpty(carAmtCostInfoAdd)) {
            runParams.put("hasAppend",WhetherEnum.YES.getCode());
            appendLoanAmount=appendLoanAmount.add(Convert.toBigDecimal(carAmtCostInfoAdd.getLoanAmt(), BigDecimal.ZERO));
            appendDiscountAmount=appendDiscountAmount.add(Convert.toBigDecimal(carAmtCostInfoAdd.getDiscountAmt(), BigDecimal.ZERO));
            appendFinalPayment=appendFinalPayment.add(Convert.toBigDecimal(carAmtCostInfoAdd.getTailPayAmt(), BigDecimal.ZERO));
        }else{
            runParams.put("hasAppend",WhetherEnum.NO.getCode());
        }
        runParams.put("appendLoanAmount",appendLoanAmount);
        runParams.put("appendDiscountAmount",appendDiscountAmount);
        runParams.put("appendFinalPayment",appendFinalPayment);
        loanAmount=loanAmount.add(appendLoanAmount).add(carLoanAmount);
        runParams.put("loanAmount",loanAmount);

        tailPayAmt=tailPayAmt.add(carDiscountAmount).add(appendDiscountAmount);
        runParams.put("tailPayAmt",tailPayAmt);

        subsidyTotalAmt=subsidyTotalAmt.add(appendFinalPayment).add(carFinalPayment);
        runParams.put("subsidyTotalAmt",subsidyTotalAmt);

        CaseChannelInfo caseChannelInfo = caseChannelInfoService.getOne(Wrappers.<CaseChannelInfo>query().lambda()
                .eq(CaseChannelInfo::getApplyNo, applyNo));
        if (ObjectUtils.isNotEmpty(caseChannelInfo)) {
            /**经销商名称*/
            runParams.put("dealerName", caseChannelInfo.getDealerName());
            /**车商名称*/
            runParams.put("carDealersName", caseChannelInfo.getCarDealersName());
            runParams.put("dealerChannelName", caseChannelInfo.getCarDealersName());

            /**---------------------------------   渠道信息    --------------------------------**/
            ChannelBaseInfo channelBaseInfo = channelBaseInfoService.getOne(Wrappers.<ChannelBaseInfo>query().lambda()
                    .eq(ChannelBaseInfo::getChannelCode, caseChannelInfo.getDealerNo()));
            if (ObjectUtils.isNotEmpty(channelBaseInfo)) {
                /**经销商省份*/
                runParams.put("channelProvince", channelBaseInfo.getChannelProvince());
                /**经销商城市*/
                runParams.put("channelCity", channelBaseInfo.getChannelCity());
                /**渠道归属*/
                runParams.put("channelBelong", channelBaseInfo.getChannelBelong());
                /**经销商省份*/
                runParams.put("channelProvince", channelBaseInfo.getChannelProvince());
                /**经销商城市*/
                runParams.put("channelCity", channelBaseInfo.getChannelCity());

                /**渠道风险信息*/
                /**合作商优质等级*/
                ChannelRiskInfo channelRiskInfo = channelRiskInfoService.getOne(Wrappers.<ChannelRiskInfo>query().lambda()
                        .eq(StringUtils.isNotBlank(caseChannelInfo.getDealerNo()), ChannelRiskInfo::getChannelId, channelBaseInfo.getChannelId())
                        .eq(StringUtils.isNotBlank(channelBaseInfo.getBusinessType()), ChannelRiskInfo::getBusinessType, caseBaseInfo.getBusinessType()));

                if (ObjectUtils.isNotEmpty(channelRiskInfo)) {
                    /**优质等级*/
                    runParams.put("qualityGrade", channelRiskInfo.getQualityGrade());
                    /**合作商评级*/
                    runParams.put("channelGrade", channelRiskInfo.getChannelGrade());
                }
                /**车商优质等级*/
                if(StringUtils.isNotBlank(caseChannelInfo.getCarDealersId())){
                    ChannelRiskInfo criskInfo = channelRiskInfoService.getOne(Wrappers.<ChannelRiskInfo>query().lambda()
                            .eq(ChannelRiskInfo::getChannelId, caseChannelInfo.getCarDealersId())
                            .eq(ChannelRiskInfo::getBusinessType, caseBaseInfo.getBusinessType()));
                    if(ObjectUtils.isNotEmpty(criskInfo)){
                        runParams.put("dealerQualityGrade", criskInfo.getQualityGrade());
                    }else {
                        runParams.put("dealerQualityGrade", "");
                    }
                }else{
                    runParams.put("dealerQualityGrade", "");
                }
            }
        }
        /**add by fangchenliang*/
        int commonBorrowers=caseCustInfoService.count(Wrappers.<CaseCustInfo>lambdaQuery().eq(CaseCustInfo::getApplyNo,applyNo).eq(CaseCustInfo::getCustRole, CustRoleEnum.COMMONCSUT.getCode()));
        runParams.put("hasCommonBorrower", commonBorrowers>0?"yes":"no");
        int bails=caseCustInfoService.count(Wrappers.<CaseCustInfo>lambdaQuery().eq(CaseCustInfo::getApplyNo,applyNo).eq(CaseCustInfo::getCustRole, CustRoleEnum.GUARANTOR.getCode()));
        runParams.put("hasBail", bails>0?"yes":"no");
        runParams.put("remoteSign","no");
        CaseCustInfo caseCustInfo=caseCustInfoService.getOne(Wrappers.<CaseCustInfo>lambdaQuery().eq(CaseCustInfo::getApplyNo,applyNo).eq(CaseCustInfo::getCustRole, CustRoleEnum.MIANCUST.getCode()));
        CaseCustIndividual custIndividual=caseCustIndividualService.getOne(Wrappers.<CaseCustIndividual>lambdaQuery().eq(CaseCustIndividual::getCustId,caseCustInfo.getId()));
        runParams.put("drivingType",custIndividual.getDrivingType());
        /**附加贷*/
        List<FinFinancingItems> finFinancingItemsList=applyFinancingItemsService.list(Wrappers.<FinFinancingItems>lambdaQuery().eq(FinFinancingItems::getApplyNo,applyNo));
        String itemsName="";
        if(CollectionUtils.isNotEmpty(finFinancingItemsList)){
            for (FinFinancingItems items:finFinancingItemsList){
                itemsName=items.getFinanceItemName()+",";
            }
        }
        runParams.put("financeItemName",itemsName);

        log.info("------------------公共原子规则组装 End --------------------");
        return runParams;
    }

    public JSONObject getCommonAtomRunParamsLoan(String contractNo){
        log.info("------------------放款审核原子规则组装 Start --------------------");
        CaseContractInfo caseContractInfo= caseContractInfoService.getOne(Wrappers.<CaseContractInfo>query().lambda().eq(CaseContractInfo::getContractNo,contractNo));
        CaseBaseInfo caseBaseInfo = caseBaseInfoService.getOne(Wrappers.<CaseBaseInfo>query().lambda()
                .eq(CaseBaseInfo::getApplyNo, caseContractInfo.getApplyNo()));
        JSONObject loanParams=getCommonAtomRunParams(caseContractInfo.getApplyNo());
        /**放款模式*/
        loanParams.put("lendingMode",caseContractInfo.getLendingMode());
        /**放款审核人员*/
        loanParams.put("loanAuditor",caseContractInfo.getLoanAuditor());

        /**是否归档超期/是否暂停放款*/
        if(WhetherEnum.YES.getCode().equals(caseContractInfo.getIsOverdue())){
            loanParams.put("isOverdue", WhetherEnum.YES.getCode());
        }else {
            loanParams.put("isOverdue", WhetherEnum.NO.getCode());
        }
        if(WhetherEnum.YES.getCode().equals(caseContractInfo.getIsLock())){
            loanParams.put("isLock", WhetherEnum.YES.getCode());
        }else {
            loanParams.put("isLock", WhetherEnum.NO.getCode());
        }
        CarInsuranceInfo carInsuranceInfo=carInsuranceInfoService.getOne(Wrappers.<CarInsuranceInfo>query().lambda().eq(CarInsuranceInfo::getContractNo,contractNo),false);
        if(ObjectUtils.isNotEmpty(carInsuranceInfo)){
            /**保单类型*/
            loanParams.put("insuranceMode",carInsuranceInfo.getInsuranceMode());
        }

        LoanBankCardInfo loanBankCardInfo=loanBankCardInfoService.getOne(Wrappers.<LoanBankCardInfo>query().lambda().eq(LoanBankCardInfo::getContractNo,contractNo),false);
        if(ObjectUtils.isNotEmpty(loanBankCardInfo)) {
            /**银行签约方式*/
            loanParams.put("authorizeWay", loanBankCardInfo.getAuthorizeWay());
            /**还款银行*/
            loanParams.put("bankCode", loanBankCardInfo.getBankCode());
            /**开票单位名称*/
            loanParams.put("bankCode", loanBankCardInfo.getBankCode());
        }

        CarInvoiceInfo carInvoiceInfo=carInvoiceInfoService.getOne(Wrappers.<CarInvoiceInfo>query().lambda().eq(CarInvoiceInfo::getContractNo,contractNo),false);
        if(ObjectUtils.isNotEmpty(carInvoiceInfo)) {
            /**开票单位*/
            loanParams.put("makeInvoiceUnit", carInvoiceInfo.getMakeInvoiceUnit());
            loanParams.put("officeEqualDealer", loanParams.get("makeInvoiceUnit").equals(loanParams.get("dealerName"))?"yes":"no");
        }
        /**计算审批时效*/
        Long limitTime =DateUtil.betweenDay( caseBaseInfo.getPassLastDate()==null?caseBaseInfo.getProcessorEndTime():caseBaseInfo.getPassLastDate(),new Date(),true);
        loanParams.put("limitTime", limitTime.intValue());
        /**电子签约*/
        ComAttachmentFile loanContractFile = comAttaManageService.getFile(AttachmentUniqueCodeEnum.LOAN_CONTRACT_FILE.getCode(), contractNo);
        ComAttachmentFile remitAuthorizationFile = comAttaManageService.getFile(AttachmentUniqueCodeEnum.REMIT_AUTHORIZATION_FILE.getCode(), contractNo);
        if(ObjectUtils.isNotEmpty(loanContractFile)&&ObjectUtils.isNotEmpty(remitAuthorizationFile)
                &&IsTypeNumEnum.YES.getCode().equals(remitAuthorizationFile.getIsElectronic())&&IsTypeNumEnum.YES.getCode().equals(loanContractFile.getIsElectronic())){
            loanParams.put("isEleSign", WhetherEnum.YES.getCode());
        }else {
            loanParams.put("isEleSign", WhetherEnum.NO.getCode());
        }
        log.info("------------------放款审核原子规则组装 End --------------------");
        return loanParams;
    }

    public JSONObject getCommonAtomRunParamsActive(String contractNo){
        log.info("------------------激活原子规则组装 Start --------------------");
        JSONObject loanParams = new JSONObject();
        CaseContractInfo caseContractInfo = caseContractInfoService.getOne(Wrappers.<CaseContractInfo>query().lambda()
                .eq(CaseContractInfo::getContractNo,contractNo));
        CaseBaseInfo caseBaseInfo = caseBaseInfoService.getOne(Wrappers.<CaseBaseInfo>query().lambda()
                .eq(CaseBaseInfo::getApplyNo,caseContractInfo.getApplyNo()));
        if(ObjectUtils.isNotEmpty(caseContractInfo)){
            CaseChannelInfo caseChannelInfo = caseChannelInfoService.getOne(Wrappers.<CaseChannelInfo>query().lambda()
                    .eq(CaseChannelInfo::getApplyNo, caseContractInfo.getApplyNo()));
            if (ObjectUtils.isNotEmpty(caseChannelInfo)) {
                /**经销商名称*/
                loanParams.put("dealerName", caseChannelInfo.getDealerName());
                /**车商名称*/
                loanParams.put("carDealersName", caseChannelInfo.getCarDealersName());
                /**---------------------------------   渠道信息    --------------------------------**/
                ChannelBaseInfo channelBaseInfo = channelBaseInfoService.getOne(Wrappers.<ChannelBaseInfo>query().lambda()
                        .eq(ChannelBaseInfo::getChannelCode, caseChannelInfo.getDealerNo()));
                /**直营车商的案件从渠道案件表获取直营车商ID可在渠道付款账户表查询付款账户信息*/
                List<ChannelReceivablesAccount> account=new ArrayList<>();
                //0-主体，1-车商
                if(AfsEnumUtil.key(PaymentObjectEnum.partners).equals(channelBaseInfo.getPaymentObject())){
                    account = accountInfoService.list(Wrappers.<ChannelReceivablesAccount>query().lambda()
                            .eq(ChannelReceivablesAccount::getChannelId, channelBaseInfo.getId())
                            .eq(ChannelReceivablesAccount::getStatus,ChannelOnlineEnum.ENABLE.getCode())
                            .eq(ChannelReceivablesAccount::getCollectionType,AfsEnumUtil.key(CollectionTypeEnum.CAR_FUND))
                            .eq(ChannelReceivablesAccount::getAccountAttribute,caseBaseInfo.getBusinessType()));
                }else if(AfsEnumUtil.key(PaymentObjectEnum.car_dealer).equals(channelBaseInfo.getPaymentObject())){
                    account = accountInfoService.list(Wrappers.<ChannelReceivablesAccount>query().lambda()
                            .eq(StringUtils.isNotBlank(caseChannelInfo.getCarDealersId()),ChannelReceivablesAccount::getChannelId, Long.valueOf(caseChannelInfo.getCarDealersId()!=null?caseChannelInfo.getCarDealersId():"-1"))
                            .eq(ChannelReceivablesAccount::getAccountAttribute,caseBaseInfo.getBusinessType())
                            .eq(ChannelReceivablesAccount::getCollectionType,AfsEnumUtil.key(CollectionTypeEnum.CAR_FUND))
                            .eq(ChannelReceivablesAccount::getStatus,ChannelOnlineEnum.ENABLE.getCode()));
                }
                loanParams.put("receivingBank", account.get(0).getReceivingBank());
            }
            if (ObjectUtils.isNotEmpty(caseBaseInfo)) {
                /**业务类型*/
                loanParams.put("businessType", caseBaseInfo.getBusinessType());

                /**车辆类型*/
                loanParams.put("carType", caseBaseInfo.getCarType());
            }
        }
        log.info("------------------激活原子规则组装 End --------------------");
        return loanParams;
    }
}
